package com.chixing.ih.module.programmer.mapper.provider;

import com.chixing.ih.module.programmer.pojo.Work;
import com.chixing.ih.util.EmptyUtil;
import org.apache.ibatis.jdbc.SQL;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: 刘岩
 * Date: 2020-09-25
 * Time: 19:48
 *
 * @version 1.0
 */
public class WorkMapperProvider {


    public String insertOne() {
        return new SQL() {{
            INSERT_INTO("tbl_work");
            VALUES("user_id", "#{userId}");
        }}.toString();
    }


    public String deleteOneById() {
        return null;
    }


    public String getOneById() {
        return new SQL() {{
            SELECT("*");
            FROM("tbl_work");
            WHERE("user_id=#{programmerId}");
        }}.toString();

    }


    public String listAll() {
        return null;
    }


    public String updateOne(Work work) {
        return new SQL() {{
            UPDATE("tbl_work");
            SET("working_day_begin_time=#{WDBT}");
            SET("working_day_end_time=#{WDET}");
            SET("weekend_working_begin_time=#{WWBT}");
            SET("weekend_working_end_time=#{WWET}");
            SET("weekly_time=#{weeklyTime}");
            SET("work_way=#{workWay}");
            SET("region_province=#{regionProvince}");
            SET("region_city=#{regionCity}");
            SET("salary=#{salary}");
            if (!EmptyUtil.isEmpty(work.getWorkStatus())) {
                SET("work_status=#{workStatus}");
            }
            if (!EmptyUtil.isEmpty(work.getCreateTime())) {
                SET("create_time=#{createTime}");
            }
            if (!EmptyUtil.isEmpty(work.getWorkStatus())) {
                SET("is_deleted=#{isDeleted}");
            }
            WHERE("user_id=#{programmerId}");

        }}.toString();


    }


    public String deleteAll() {
        return null;
    }

}
